#ifndef _DEVICE_SCAN_H_
#define _DEVICE_SCAN_H_

#include "spk_packet.h"

class cls_device_scan : public spk_packet
{

public:
    cls_device_scan(cls_spkcam *p_app);
    ~cls_device_scan();

    cls_spkcam *app;
    device_info *cfg_src;
    device_info *cfg_cur;

    /*发送一个广播扫描信息包到广播地址255，此类将会在后台线程接收并处理设备返回的消息*/
    int scan(void);

    /*本机IP地址*/
    std::string my_ip_addr;
    /**/
    std::string name;
    

private:
    std::thread *rx_thread;
    static void rx_packet_thread(void *arg);

    int count;
    int fd;
    int udp_init(int port = -1);
    virtual int io_write(void *data, int len, void *param = NULL);
    cls_device_ctrl *ctrl;
    static void on_rx_packet(void *rx_buffer, int len, u8 type, void *param);
    static int io_read(void *data, int len, int time_out_ms, void *param);
};

#endif //  _DEVICE_SCAN_H_
